<?php


abstract class BaseEntrevista extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $cp_entrevista;


	
	protected $cf_estudiante;


	
	protected $cf_trabajador;


	
	protected $fecha;


	
	protected $motivo;


	
	protected $diagnostico;


	
	protected $observacion;


	
	protected $fecha_revision;


	
	protected $observacion_revision;


	
	protected $decision_revision;


	
	protected $estatus;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getCpEntrevista()
	{

		return $this->cp_entrevista;
	}

	
	public function getCfEstudiante()
	{

		return $this->cf_estudiante;
	}

	
	public function getCfTrabajador()
	{

		return $this->cf_trabajador;
	}

	
	public function getFecha($format = 'Y-m-d')
	{

		if ($this->fecha === null || $this->fecha === '') {
			return null;
		} elseif (!is_int($this->fecha)) {
						$ts = strtotime($this->fecha);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [fecha] as date/time value: " . var_export($this->fecha, true));
			}
		} else {
			$ts = $this->fecha;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getMotivo()
	{

		return $this->motivo;
	}

	
	public function getDiagnostico()
	{

		return $this->diagnostico;
	}

	
	public function getObservacion()
	{

		return $this->observacion;
	}

	
	public function getFechaRevision($format = 'Y-m-d')
	{

		if ($this->fecha_revision === null || $this->fecha_revision === '') {
			return null;
		} elseif (!is_int($this->fecha_revision)) {
						$ts = strtotime($this->fecha_revision);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [fecha_revision] as date/time value: " . var_export($this->fecha_revision, true));
			}
		} else {
			$ts = $this->fecha_revision;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getObservacionRevision()
	{

		return $this->observacion_revision;
	}

	
	public function getDecisionRevision()
	{

		return $this->decision_revision;
	}

	
	public function getEstatus()
	{

		return $this->estatus;
	}

	
	public function setCpEntrevista($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cp_entrevista !== $v) {
			$this->cp_entrevista = $v;
			$this->modifiedColumns[] = EntrevistaPeer::CP_ENTREVISTA;
		}

	} 
	
	public function setCfEstudiante($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cf_estudiante !== $v) {
			$this->cf_estudiante = $v;
			$this->modifiedColumns[] = EntrevistaPeer::CF_ESTUDIANTE;
		}

	} 
	
	public function setCfTrabajador($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cf_trabajador !== $v) {
			$this->cf_trabajador = $v;
			$this->modifiedColumns[] = EntrevistaPeer::CF_TRABAJADOR;
		}

	} 
	
	public function setFecha($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [fecha] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->fecha !== $ts) {
			$this->fecha = $ts;
			$this->modifiedColumns[] = EntrevistaPeer::FECHA;
		}

	} 
	
	public function setMotivo($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->motivo !== $v) {
			$this->motivo = $v;
			$this->modifiedColumns[] = EntrevistaPeer::MOTIVO;
		}

	} 
	
	public function setDiagnostico($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->diagnostico !== $v) {
			$this->diagnostico = $v;
			$this->modifiedColumns[] = EntrevistaPeer::DIAGNOSTICO;
		}

	} 
	
	public function setObservacion($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->observacion !== $v) {
			$this->observacion = $v;
			$this->modifiedColumns[] = EntrevistaPeer::OBSERVACION;
		}

	} 
	
	public function setFechaRevision($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [fecha_revision] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->fecha_revision !== $ts) {
			$this->fecha_revision = $ts;
			$this->modifiedColumns[] = EntrevistaPeer::FECHA_REVISION;
		}

	} 
	
	public function setObservacionRevision($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->observacion_revision !== $v) {
			$this->observacion_revision = $v;
			$this->modifiedColumns[] = EntrevistaPeer::OBSERVACION_REVISION;
		}

	} 
	
	public function setDecisionRevision($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->decision_revision !== $v) {
			$this->decision_revision = $v;
			$this->modifiedColumns[] = EntrevistaPeer::DECISION_REVISION;
		}

	} 
	
	public function setEstatus($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->estatus !== $v) {
			$this->estatus = $v;
			$this->modifiedColumns[] = EntrevistaPeer::ESTATUS;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->cp_entrevista = $rs->getString($startcol + 0);

			$this->cf_estudiante = $rs->getString($startcol + 1);

			$this->cf_trabajador = $rs->getString($startcol + 2);

			$this->fecha = $rs->getDate($startcol + 3, null);

			$this->motivo = $rs->getString($startcol + 4);

			$this->diagnostico = $rs->getString($startcol + 5);

			$this->observacion = $rs->getString($startcol + 6);

			$this->fecha_revision = $rs->getDate($startcol + 7, null);

			$this->observacion_revision = $rs->getString($startcol + 8);

			$this->decision_revision = $rs->getString($startcol + 9);

			$this->estatus = $rs->getString($startcol + 10);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 11; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Entrevista object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(EntrevistaPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			EntrevistaPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(EntrevistaPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = EntrevistaPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setCpEntrevista($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += EntrevistaPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = EntrevistaPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = EntrevistaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getCpEntrevista();
				break;
			case 1:
				return $this->getCfEstudiante();
				break;
			case 2:
				return $this->getCfTrabajador();
				break;
			case 3:
				return $this->getFecha();
				break;
			case 4:
				return $this->getMotivo();
				break;
			case 5:
				return $this->getDiagnostico();
				break;
			case 6:
				return $this->getObservacion();
				break;
			case 7:
				return $this->getFechaRevision();
				break;
			case 8:
				return $this->getObservacionRevision();
				break;
			case 9:
				return $this->getDecisionRevision();
				break;
			case 10:
				return $this->getEstatus();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = EntrevistaPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getCpEntrevista(),
			$keys[1] => $this->getCfEstudiante(),
			$keys[2] => $this->getCfTrabajador(),
			$keys[3] => $this->getFecha(),
			$keys[4] => $this->getMotivo(),
			$keys[5] => $this->getDiagnostico(),
			$keys[6] => $this->getObservacion(),
			$keys[7] => $this->getFechaRevision(),
			$keys[8] => $this->getObservacionRevision(),
			$keys[9] => $this->getDecisionRevision(),
			$keys[10] => $this->getEstatus(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = EntrevistaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setCpEntrevista($value);
				break;
			case 1:
				$this->setCfEstudiante($value);
				break;
			case 2:
				$this->setCfTrabajador($value);
				break;
			case 3:
				$this->setFecha($value);
				break;
			case 4:
				$this->setMotivo($value);
				break;
			case 5:
				$this->setDiagnostico($value);
				break;
			case 6:
				$this->setObservacion($value);
				break;
			case 7:
				$this->setFechaRevision($value);
				break;
			case 8:
				$this->setObservacionRevision($value);
				break;
			case 9:
				$this->setDecisionRevision($value);
				break;
			case 10:
				$this->setEstatus($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = EntrevistaPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setCpEntrevista($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setCfEstudiante($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setCfTrabajador($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setFecha($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setMotivo($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setDiagnostico($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setObservacion($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setFechaRevision($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setObservacionRevision($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setDecisionRevision($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setEstatus($arr[$keys[10]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(EntrevistaPeer::DATABASE_NAME);

		if ($this->isColumnModified(EntrevistaPeer::CP_ENTREVISTA)) $criteria->add(EntrevistaPeer::CP_ENTREVISTA, $this->cp_entrevista);
		if ($this->isColumnModified(EntrevistaPeer::CF_ESTUDIANTE)) $criteria->add(EntrevistaPeer::CF_ESTUDIANTE, $this->cf_estudiante);
		if ($this->isColumnModified(EntrevistaPeer::CF_TRABAJADOR)) $criteria->add(EntrevistaPeer::CF_TRABAJADOR, $this->cf_trabajador);
		if ($this->isColumnModified(EntrevistaPeer::FECHA)) $criteria->add(EntrevistaPeer::FECHA, $this->fecha);
		if ($this->isColumnModified(EntrevistaPeer::MOTIVO)) $criteria->add(EntrevistaPeer::MOTIVO, $this->motivo);
		if ($this->isColumnModified(EntrevistaPeer::DIAGNOSTICO)) $criteria->add(EntrevistaPeer::DIAGNOSTICO, $this->diagnostico);
		if ($this->isColumnModified(EntrevistaPeer::OBSERVACION)) $criteria->add(EntrevistaPeer::OBSERVACION, $this->observacion);
		if ($this->isColumnModified(EntrevistaPeer::FECHA_REVISION)) $criteria->add(EntrevistaPeer::FECHA_REVISION, $this->fecha_revision);
		if ($this->isColumnModified(EntrevistaPeer::OBSERVACION_REVISION)) $criteria->add(EntrevistaPeer::OBSERVACION_REVISION, $this->observacion_revision);
		if ($this->isColumnModified(EntrevistaPeer::DECISION_REVISION)) $criteria->add(EntrevistaPeer::DECISION_REVISION, $this->decision_revision);
		if ($this->isColumnModified(EntrevistaPeer::ESTATUS)) $criteria->add(EntrevistaPeer::ESTATUS, $this->estatus);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(EntrevistaPeer::DATABASE_NAME);

		$criteria->add(EntrevistaPeer::CP_ENTREVISTA, $this->cp_entrevista);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getCpEntrevista();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setCpEntrevista($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setCfEstudiante($this->cf_estudiante);

		$copyObj->setCfTrabajador($this->cf_trabajador);

		$copyObj->setFecha($this->fecha);

		$copyObj->setMotivo($this->motivo);

		$copyObj->setDiagnostico($this->diagnostico);

		$copyObj->setObservacion($this->observacion);

		$copyObj->setFechaRevision($this->fecha_revision);

		$copyObj->setObservacionRevision($this->observacion_revision);

		$copyObj->setDecisionRevision($this->decision_revision);

		$copyObj->setEstatus($this->estatus);


		$copyObj->setNew(true);

		$copyObj->setCpEntrevista(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new EntrevistaPeer();
		}
		return self::$peer;
	}

} 